import { modal } from 'vue-strap'
import { showMsg, setSubscription } from '../../../../../vuex/action.js'

export default {
  data() {
    return {
      showSubscriptionModal: false,
      details: []
    }
  },
  props: ['betaId', 'subType', 'type'],
  methods: {
    showSubscriptionDialog() {
      let params = {
        id: this.betaId,
        type: this.type
      }
      if (this.subType) {
        params = Object.assign(params, {subType: this.subType})
      }
      this.xSetSubscription(params)
        .then((res) => {
          this.details = res.data.statistics
          this.showSubscriptionModal = true
        }).catch((res) => {
          this.xShowMsg({
            type: 'danger',
            content: res.error_msg
          })
        })
    }
  },
  vuex: {
    actions: {
      xShowMsg: showMsg,
      xSetSubscription: setSubscription
    }
  },
  components: {
    modal: modal
  }
}
